Hi guys, here is my code to check if the views inside the module match any of the strings inside the arrays (which contain the original views).
View v = null
string res = ""
string viewsMRD[] = {"[Standard] Attributes","[Standard] Traceability","[Standard] Document","[Standard] Requirements"}
string viewsPTR[] = {"[Standard] PTR"}
string viewsQA[] = {"Attributes","Clinical","Document","Electrical","Logistics","Manufacturing","Marketing","Mechanical","ProjMgt","QARA","Software","SyergyDOORS","SysEng","TestEng"}
string viewsFMEA[] = {"BookView","WorkingView"}
string s
Item moduleitem
string modulename
string modulechecker
int MRD,PTR,QA,FMEA
//Possible to force nomenclature of modules, so that the code can check fullName of the module and select the appropriate counter/array to compare the views against.
void compareMRD(int MRD, Module m)
{
for s in views(m) do
{
bool equal = false
//MRD = 0 //counter for generic loop below
for MRD in 0:3 do
{
//Comparison code here
if (s == viewsMRD[MRD])
{
equal = true
print MRD "\n"
}
else
{
print MRD "\n"
}
}
if (equal != true)
{
v = view(s) //handle to current view in loop
res = set(v,none,null)
print "It's done."
if(!null res)
{
ack("Error setting permissions in at least 1 view.")
}
}
}
}
for moduleitem in current Project do
{
MRD=0
PTR=1
QA=0
FMEA=0 //Reset counters
if((type moduleitem) == "Formal")
{
modulename = fullName(moduleitem)
modulechecker = name(moduleitem) //just get name of module not path
print modulechecker
//print modulename
if(name(moduleitem) == "MRD")
{
edit(modulename, true, true, false)
Module moo = current
compareMRD(MRD,moo)
}
Module moo = current
save(moo)
//close(m,false)
}
}
TooDifficult - Wed Dec 22 00:08:09 EST 2010 |
Re: code to control views being private/public The code runs fine, but when it gets to a non-matching view, that is, a user-added view, the set-view permission statement stops working. I get the if null case, and then the error message. When I go into the manage views tab to have a look at the permissions, I see myloginname RMCDA, and also Everyone R That is, I see 2 separate permission sets, whereas each of the original ones only have Everyone RMCDA. In other words, the code is not working. It runs through the loops fine, I just don't know what is affecting the success of that set-view statement. Any idea what's wrong? Is it because I have the view in the active window that the script can't run on it? Simply because it's being 'edited' when the script means to set it to no-access? Thanks, TooDiff |
Re: code to control views being private/public |
Re: code to control views being private/public The code runs fine, but when it gets to a non-matching view, that is, a user-added view, the set-view permission statement stops working. I get the if null case, and then the error message. When I go into the manage views tab to have a look at the permissions, I see myloginname RMCDA, and also Everyone R That is, I see 2 separate permission sets, whereas each of the original ones only have Everyone RMCDA. In other words, the code is not working. It runs through the loops fine, I just don't know what is affecting the success of that set-view statement. Also, that set statement seems to work very selectively. I've made an include file that contains all the functions to generate a module with pre scripted views and attributes. After the code line to save the views, I've also added a set-view permissions statement, which makes the pre scripted view read only to users. Funny thing is, this thing only works for the default view. So only one of the views has been affected by the set statement; the rest all remain Everyone RMCDA. Any idea what's wrong? Is it because I have the view in the active window that the script can't run on it? Simply because it's being 'edited' when the script means to set it to no-access? Thanks, TooDiff |
Re: code to control views being private/public |
Re: code to control views being private/public First off, you don't need to 'edit' the module, you can modify views in 'read' mode, and saving the view is enough you don't save the module. Perhaps some of your views have 'inherited' access and therefore you cannot modify the individual settings, you'd need to change the view to 'specific' first. I don't have my DXL manual handy, but I think the following will help bool IsInherit isInherit(v, IsInherit) if (IsInherit) then specific(v) // or is is 'setSpecific'? // now try to set the view Now I wonder if you must save the view. To do that you may need to first load the view, change its access, and save it but I don't recall. But surely someone will help me out on that. -Louie If you must save the module, you should do this: Module moo = edit(...) bla bla bla save(moo) close(moo) Relying on 'current module' to get your handle is hopeless. |
Re: code to control views being private/public Thanks for the reply. Thanks for your checker snippet. I've also found the problem by having a look at the access control code example in the DXL Manual. The problem seems to be that set only takes read|modify|delete|control? I do not see "none" as part of those choices. Is it possible to make a selection of that particular option in some other way? the set statement works fine with modify or delete. I see the access right change to RM or RMCD, etc. Thanks, 2Diff |
Re: code to control views being private/public
Louie,
// Make all views private by removing "Everyone Else" permissions
/*string s = "" //Will store the name of a view
string res = "" //Will store the returned result from a function
View v = null*/
View v = null
string res = ""
string viewsMRD[] = {"[Standard] Attributes","[Standard] Traceability","[Standard] Document","[Standard] Requirements"}
string viewsPTR[] = {"[Standard] PTR"}
string viewsQA[] = {"Attributes","Clinical","Document","Electrical","Logistics","Manufacturing","Marketing","Mechanical","ProjMgt","QARA","Software","SyergyDOORS","SysEng","TestEng"}
string viewsFMEA[] = {"BookView","WorkingView"}
string s
Item moduleitem
string modulename
string modulechecker
int MRD,PTR,QA,FMEA
//Possible to force nomenclature of modules, so that the code can check fullName of the module and select the appropriate counter/array to compare the views against.
void compareMRD(int MRD, Module m)
{
for s in views(m) do
{
bool equal = false
//MRD = 0 //counter for generic loop below
for MRD in 0:3 do
{
//Comparison code here
if (s == viewsMRD[MRD])
{
equal = true
print MRD "\n"
print equal "\n"
}
else
{
print MRD "\n"
}
}
if (equal != true)
{
print "Get rid of this one \n"
v = view(s) //handle to current view in loop
bool IsAccessInherited
isAccessInherited(v,IsAccessInherited)
if (IsAccessInherited == true)
{
specific(v)
}
res = set(v,none,null)
if(!null res)
{
ack("Error setting permissions in at least 1 view.")
}
}
}
}
for moduleitem in current Project do
{
MRD=0
PTR=1
QA=0
FMEA=0 //Reset counters
if((type moduleitem) == "Formal")
{
modulename = fullName(moduleitem)
modulechecker = name(moduleitem) //just get name of module not path
if(name(moduleitem) == "MRD")
{
Module moo = edit(modulename, true, true, false)
compareMRD(MRD,moo)
}
Module moo = current
save(moo)
//close(m,false)
}
}
|
Re: code to control views being private/public TooDifficult - Wed Dec 22 17:00:49 EST 2010
Louie,
// Make all views private by removing "Everyone Else" permissions
/*string s = "" //Will store the name of a view
string res = "" //Will store the returned result from a function
View v = null*/
View v = null
string res = ""
string viewsMRD[] = {"[Standard] Attributes","[Standard] Traceability","[Standard] Document","[Standard] Requirements"}
string viewsPTR[] = {"[Standard] PTR"}
string viewsQA[] = {"Attributes","Clinical","Document","Electrical","Logistics","Manufacturing","Marketing","Mechanical","ProjMgt","QARA","Software","SyergyDOORS","SysEng","TestEng"}
string viewsFMEA[] = {"BookView","WorkingView"}
string s
Item moduleitem
string modulename
string modulechecker
int MRD,PTR,QA,FMEA
//Possible to force nomenclature of modules, so that the code can check fullName of the module and select the appropriate counter/array to compare the views against.
void compareMRD(int MRD, Module m)
{
for s in views(m) do
{
bool equal = false
//MRD = 0 //counter for generic loop below
for MRD in 0:3 do
{
//Comparison code here
if (s == viewsMRD[MRD])
{
equal = true
print MRD "\n"
print equal "\n"
}
else
{
print MRD "\n"
}
}
if (equal != true)
{
print "Get rid of this one \n"
v = view(s) //handle to current view in loop
bool IsAccessInherited
isAccessInherited(v,IsAccessInherited)
if (IsAccessInherited == true)
{
specific(v)
}
res = set(v,none,null)
if(!null res)
{
ack("Error setting permissions in at least 1 view.")
}
}
}
}
for moduleitem in current Project do
{
MRD=0
PTR=1
QA=0
FMEA=0 //Reset counters
if((type moduleitem) == "Formal")
{
modulename = fullName(moduleitem)
modulechecker = name(moduleitem) //just get name of module not path
if(name(moduleitem) == "MRD")
{
Module moo = edit(modulename, true, true, false)
compareMRD(MRD,moo)
}
Module moo = current
save(moo)
//close(m,false)
}
}
|
Re: code to control views being private/public llandale - Wed Dec 22 19:05:32 EST 2010 Paul Miller Melbourne, Australia |
Re: code to control views being private/public llandale - Wed Dec 22 19:05:32 EST 2010 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: code to control views being private/public Mathias Mamsch - Thu Jan 06 17:38:40 EST 2011 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS if (null s) s = "" in order to deal with strange function parameter behavior. I'm suspecting that an empty string isn't null, its just empty but the null(string) function returns true in both cases, and retrieving the string value returns the same value (no characters). In any case I avoid s=null; I always set it empty: s="".
|
Re: code to control views being private/public SystemAdmin - Wed Dec 22 23:00:48 EST 2010 Paul Miller Melbourne, Australia
OK, so I had an issue with "null" vis-a-vis characters, but I think I resolve that by using "charOf(0)" which is ASCII null. c=null means erase it; c=charOf(0) means set it to ascii null. and buf[5]=charof(0) truncated the Buffer except when used by tempStringOf(buf), but I digress.... |